﻿@using System
@using MZBlog.Core.Documents
@using MZBlog.Core.Extensions
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<MZBlog.Core.ViewProjections.Admin.AllBlogPostsViewModel>
@{
    Layout = "_AdminLayout.cshtml";
}
<div class="row">
    <ol class="breadcrumb">
        <li><i class="fa fa-dashboard"></i> <a href="~/mz-admin">控制面板</a> </li>
        <li class="active"><i class="fa fa-list"></i> 文章管理</li>
    </ol>
</div>
<div class="row">
    <table class="table table-bordered table-condensed table-striped">
        <thead>
            <tr>
                <th class="text-center" style="width:46px;"></th>
                <th>标题</th>
                <th>阅读次数</th>
                <th>发布时间</th>
                <th class="text-center" style="width:46px;"></th>
            </tr>
        </thead>
        <tbody>
            @foreach (var blogPost in Model.Posts)
            {
                <tr>
                    <td>
                        <a href="~/mz-admin/posts/edit/@blogPost.Id" class="btn btn-default btn-xs">编辑</a>
                    </td>
                    <td>
                        <a href="@blogPost.GetLink()">@blogPost.Title</a>
                        @if (blogPost.Status == PublishStatus.Draft)
                        {
                            <span class="label label-warning">草稿</span>
                        }
                        else if (blogPost.PubDate > DateTime.UtcNow)
                        {
                            <span class="label label-info">即将发布</span>
                        }
                    </td>
                    <td>
                        @blogPost.ViewCount
                    </td>
                    <td>
                        @blogPost.PubDate.ToChineseTime().ToString("yyyy-MM-dd hh:mm")
                    </td>
                    <td>
                        <a href="~/mz-admin/posts/delete/@blogPost.Id" class="btn btn-danger btn-xs">删除</a>
                    </td>
                </tr>
            }
        </tbody>
    </table>
    <ul class="pager">

        @if (Model.HasPrevPage)
        {
            <li class="previous">
                @if (Model.Page == 2)
                {
                    <a href="~/mz-admin/posts/" title="较新的"><i class="glyphicon glyphicon-arrow-left"></i></a>
                }
                else
                {
                    <a href="~/mz-admin/posts/@(Model.Page - 1)" title="较新的"><i class="glyphicon glyphicon-arrow-left"></i></a>
                }
            </li>
        }
        @if (Model.HasNextPage)
        {
            <li class="next">
                <a href="~/mz-admin/posts/@(Model.Page + 1)" title="较旧的"><i class="glyphicon glyphicon-arrow-right"></i></a>
            </li>
        }
    </ul>

</div>